home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 1
/
Gekikoh Dennoh Club Vol. 1 (Japan).7z
/
Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin
/
kowin
/
archive
/
net
/
k20menus.lzh
/
k20menu.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-09-10
|
8KB
|
353 lines
/* Copyright 1992 H.Ogasawara (COR.) */
#include <corlib.h>
#include "k20menu.h"
int WindowHeapSize= 40*1024;
int total;
NET_MENU *top= NULL;
unsigned char **lp= NULL;
int font= 12;
int autoexit= FALSE,
ncflag= FALSE;
short dspmode= 0,
lock= FALSE;
WindowID Awp, Bwp;
NET_MENU nnt;
char k20[]= "k20.win";
unsigned char NetMenuFile[80],
NetLogFile[80];
unsigned char *
getword( str, ptr )
unsigned char *str, *ptr;
{
unsigned char c= ' ', d= '\t';
for(; *ptr == ' ' || *ptr == '\t' ; ptr++ );
if( *ptr == '"' ){
c= '"';
d= '\n';
ptr++;
}
for(; *ptr && *ptr != c && *ptr != d && *ptr != '\n' ; *str++= *ptr++ );
*str= '\0';
if( *ptr == '"' )
ptr++;
return ptr;
}
unsigned char *
ngetword( str, ptr, n )
unsigned char *str, *ptr;
{
for(; n-- ; ptr= getword( str, ptr ) );
return ptr;
}
unsigned char *
astrcpy( str, ptr )
unsigned char *str, *ptr;
{
while( *str++= *ptr++ );
return str;
}
unsigned char *
astrnum( str, i, c, h )
unsigned char *str;
int i, c, h;
{
unsigned char *p= str+i;
do{
*--p= c%10+'0';
}while( c/= 10 );
while( p > str )
*--p= h;
return str+i;
}
unsigned char *
fill_str( ptr, str, n )
unsigned char *ptr, *str;
{
unsigned char *lip= ptr;
ptr= astrcpy( ptr, str )-1;
for(; ptr < lip+n ; *ptr++= ' ' );
return ptr;
}
/*
ネット名 回数/今月 料金 アクセス時間 最終ログイン
-----------------------------------------------------------------------0
●でんでんネット 1000/ 20 1200円 00:00:00 92-08-27 00:00:00
01234567890123456789012345678901234567890123456789012345678901234567890
()今月の合計()00-00 1000/ 20 1200円 00:00:00 92-08-27 00:00:00
()今月の合計()00-00 Key 区域 Tel
sps 隣接 !0088-011-757-4001!0088-011-736-6379
()今月の合計()00-00 RS232C LogFile
9600 8 N 1 X ON SJIS
()今月の合計()00-00 OPT モデムコマンド
00000 AT&C1\\X1
*/
make_1line( net, ptr, m )
NET_MENU *net;
unsigned char *ptr;
{
unsigned char *lip= ptr;
int time;
unsigned char buf[256];
*ptr++= ('●'>>8);
*ptr++= ('●'&255);
ptr= fill_str( ptr, net->name, 24-2 );
/* ptr= astrcpy( ptr, net->name )-1;
for(; ptr < lip+24 ; *ptr++= ' ' );*/
if( m < 2 ){
ptr= astrnum( ptr, 4, net->count, ' ' );
*ptr++= '/';
ptr= astrnum( ptr, 4, net->tcount, ' ' );
ptr= astrnum( ptr, 6, m ? net->lyen : net->yen, ' ' );
*ptr++= ('円'>>8);
*ptr++= ('円'&255);
time= m ? net->ltime : net->ttime;
ptr= astrnum( ptr, 3, time/3600, ' ' );
*ptr++= ':';
ptr= astrnum( ptr, 2, (time/60)%60, '0' );
*ptr++= ':';
ptr= astrnum( ptr, 2, time%60, '0' );
*ptr++= ' ';
ptr= astrcpy( ptr, net->lastlogin );
}else if( m == 2 ){
ngetword( buf, net->line, 4 );
ptr= fill_str( ptr, buf, 6 );
ngetword( buf, net->line, 3 );
ptr= astrcpy( ptr, buf );
}else if( m == 3 ){
ngetword( buf, net->line, 6 );
ptr= fill_str( ptr, buf, 21 );
ngetword( buf, net->line, 5 );
ptr= astrcpy( ptr, buf );
}else if( m == 4 ){
ptr= fill_str( ptr, net->key, 6 );
ngetword( buf, net->line, 7 );
ptr= astrnum( ptr, 5, atoi2(buf), ' ' );
*ptr++= ' ';
ngetword( buf, net->line, 8 );
ptr= astrcpy( ptr, buf );
}else if( m == 5 ){
if( lock )
ptr= astrcpy( ptr, "<Lock>" );
else
ptr= astrcpy( ptr, ngetword( buf, net->line, 8 ) );
}
lip[70]= '\0';
}
static char *title[]= {
" ネット名 回数/今月 料金 アクセス時間 最終ログイン ",
" ネット名 回数/今月 L料金 LAST時間 LASTログイン ",
" ネット名 区域 電話番号 ",
" ネット名 RS232C設定 ログファイル名 ",
" ネット名 Key OPT モデムコマンド ",
" ネット名 自動ログイン手順 ",
};
make_line( net, lp )
NET_MENU *net;
unsigned char **lp;
{
astrcpy( *lp++, title[dspmode] );
make_1line( &nnt, *lp++, 0 );
lp[-1][0]= lp[-1][1]= ' ';
for(; net ; net= net->next )
make_1line( net, *lp++, dspmode );
}
NET_MENU *
searchkey( key )
unsigned char *key;
{
NET_MENU *net= top;
for(; net ; net= net->next ){
if( !strcmp( key, net->key ) )
return net;
}
return NULL;
}
/*
sps|92-08-28 15:59:12-98/20
012345678901234567890123
*/
log_count( file )
unsigned char *file;
{
FILE *fp;
unsigned char buf[256],
key[256];
static unsigned char dat[20+12],
*ptr, *str;
NET_MENU *net;
astrcpy( dat, "《今月の合計》" );
/* DATEASC( (DATEBIN(BINDATEGET())&0x0fffffff)+0x30000000, dat+14 );*/
getdate( dat+14 );
dat[14+5]= '\0';
nnt.yen= nnt.tcount= nnt.ttime= 0;
*nnt.lastlogin= '\0';
nnt.name= dat;
if( fp= fopen( file, "r" ) ){
for(; fgets( ptr= buf, 256, fp ) ;){
for( str= key ; *ptr != '|' ; *str++= *ptr++ );
*str= '\0';
if( net= searchkey( key ) ){
str= ptr;
for(; *ptr && *ptr != ' ' ; ptr++ );
for(; *ptr && *ptr != '-' ; ptr++ );
if( !*ptr )
continue;
*ptr++= '\0';
astrcpy( nnt.lastlogin, str+1 );
net->ltime= atoi2( ptr );
for(; *ptr && *ptr != '/' ; ptr++ );
if( !*ptr )
continue;
net->lyen= atoi2( ptr+1 );
astrcpy( net->lastlogin, nnt.lastlogin );
net->count++;
nnt.count++;
if( !strncmp( nnt.lastlogin, dat+14, 5 ) ){
net->tcount++;
net->ttime+= net->ltime;
net->yen+= net->lyen;
nnt.tcount++;
nnt.yen+= net->lyen;
nnt.ttime+= net->ltime;
}
}else{
ConsoleOpen();
ConsolePrint( key );
ConsolePrint( ":net_menu に無いキーワードです\r\n" );
}
}
fclose( fp );
}
}
read_net( file )
unsigned char *file;
{
FILE *fp;
unsigned char rbuf[1024],
key[256],
name[256];
if( lp ){
free( lp );
lp= NULL;
}
while( top ){
NET_MENU *net= top;
free( top->key );
top= top->next;
free( net );
}
total= 2;
ConsoleOpen();
if( fp= fopen( file, "r" ) ){
NET_MENU *net,
*prv= NULL;
unsigned char *ptr;
fgets( rbuf, 1024, fp );
fgets( rbuf, 1024, fp );
for(; fgets( ptr= rbuf, 1024, fp ) ;){
int len= strlen( rbuf );
if( *ptr == '.' )
break;
ptr= getword( key, ptr );
ptr= getword( name, ptr );
len+= strlen(key)+strlen(name)+8;
net= (NET_MENU*)malloc( sizeof( NET_MENU ) );
if( !top )
top= net;
if( net && (ptr= (unsigned char*)malloc( len )) ){
ptr= astrcpy( net->key= ptr, key );
ptr= astrcpy( net->name= ptr, name );
ptr= astrcpy( net->line= ptr, rbuf );
net->count= net->tcount=
net->ltime= net->lyen=
net->ttime= net->yen= 0;
*net->lastlogin= '\0';
if( prv )
prv->next= net;
net->next= NULL;
prv= net;
total++;
}else{
ConsolePrint( "MemoryError\r\n");
break;
}
}
fclose( fp );
}else{
ConsolePrint( file );
ConsolePrint( ":OPENできません\r\n" );
}
if( !(lp= (unsigned char**)
malloc( total*70 + sizeof( char*)*total )) ){
ConsolePrint( "MALLOC Error\r\n");
return;
}
{
int i;
unsigned char *ptr= (unsigned char*)lp+
sizeof( char*)*total;
for( i= 0 ; i< total ; i++ ){
*ptr= '\0';
lp[i]= ptr;
ptr+= 70;
}
}
}
NET_MENU *
net_count( cn )
{
NET_MENU *net= top;
for(; net && cn-- ; net= net->next );
return net;
}
net_adial( cn )
int cn;
{
EventInfo info;
int i;
char combuf[30];
NET_MENU *net= top;
net= net_count( cn );
if( net ){
ConsoleOpen();
ConsolePrint( "Dial:" );
ConsolePrint( net->name );
ConsolePrint( "\r\n" );
astrcpy( combuf, "&ac " );
strcat( combuf, net->key );
info.ComBuffer= combuf;
info.ComData= 'k20';
info.option= EventUser;
if( i= PidSearch( k20, 1 ) ){
WindowSendEventAll( i, &info );
}else{
*combuf= '"';
strcat( combuf, "\"" );
WindowLoadExec( k20, combuf, NULL, NULL );
}
}
}
a_dial( a )
{
net_adial( a );
if( autoexit )
WindowSendSignal( WindowProcessID, SignalKill, NULL );
}